home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / doors / diary / diary.c next >
Encoding:
C/C++ Source or Header  |  1992-09-29  |  2.9 KB  |  113 lines

  1. #include <exec/exec.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include "work:romconf/doorheader.h"
  5. #include <proto/exec.h>
  6. #include <string.h>
  7. #include "source:aztec/glue.h"
  8.  
  9. void creds(void);
  10. char cmd[200];
  11. char mypath[200];
  12. char tempname[400];
  13. char filename[200];
  14. char showname[200];
  15. int mynode;
  16. int Edited=0;
  17. void end(void);
  18. void LastCommand(void);
  19. #define sm sendmessage
  20. #define gu getuserstring
  21.  
  22. main(int argc,char *argv[])
  23. {
  24.    register int i;
  25.    if(argc!=2)
  26.    {
  27.       printf(".-----------------------------------------------------.\n",1);
  28.       printf("| Ami-Express Diary Version 1.0 Written by ByteMaster |\n");
  29.       printf("|     /X Development Team - The Silent Achievers      |\n");
  30.       printf("`-----------------------------------------------------'\n");
  31.       printf("\n");
  32.       printf(" This is a (XIM) for AmiExpress 2.30+\n");
  33.       printf("\n");
  34.       exit(0);
  35.    }
  36.    Register(argv[1][0]-'0');
  37.    creds();
  38.  
  39.    mynode=argv[1][0]-'0';
  40.    gu(cmd,BB_MAINLINE);
  41.    gu(filename,BB_LOCAL);
  42.    sprintf(tempname,"%sNode%d/PlayPen/%s",filename,mynode,cmd);
  43.    strcpy(mypath,argv[0]);
  44.    i=strlen(mypath)-1;
  45.    while(mypath[i]!='/' && mypath[i]!=':') i--;
  46.    mypath[i+1]='\0';
  47.  
  48.    sprintf(filename,"%s%s.dat",mypath,cmd);
  49.    sprintf(showname,"%s%s",mypath,cmd);
  50.    showgfile(showname);
  51.    Edited=1;
  52.    Editfile(tempname,0);
  53.    ShutDown();
  54.    end();
  55. }
  56. void end(void)
  57. {
  58.   exit(0);
  59. }
  60. void LastCommand(void)
  61. {
  62.   FILE *fi,*fo;
  63.   char name[200];
  64.   char date[200];
  65.   char oldname[200];
  66.   char oldplayname[200];
  67.   if(Edited)
  68.   {
  69.     gu(name,DT_NAME);
  70.     strcpy(date,GetTheDate(NULL));
  71.     sprintf(oldname,"%s.old",filename);
  72.     sprintf(oldplayname,"%s.old",tempname);
  73.      
  74.     fi=fopen(tempname,"r");
  75.     if(fi!=NULL)
  76.     {
  77.        Rename(filename,oldname);
  78.    
  79.        fo=fopen(oldplayname,"a");
  80.        if(fo==NULL)
  81.        {
  82.          sm("Error! can't save file",1);
  83.        }
  84.        else
  85.        {
  86.          fprintf(fo,"\n");
  87.          fprintf(fo,"-------------------------------------------------------------------------\n");
  88.          fprintf(fo,"[%s] %s\n",date,name);
  89.          fprintf(fo,"\n");
  90.          while(fgets(date,80,fi)!=NULL)
  91.          fprintf(fo,"%s",date);
  92.          fclose(fo);
  93.        }
  94.       fclose(fi);
  95.       DeleteFile(tempname);
  96.       sprintf(tempname,"Join >nil: %s %s to %s",oldplayname,oldname,filename);
  97.       Execute(tempname,NULL,NULL);
  98.       DeleteFile(oldplayname);
  99.       DeleteFile(oldname);
  100.     }
  101.   
  102.   }
  103.   sm("",1); sm("",1);
  104. }
  105.  
  106. void creds(void)
  107. {
  108. sm("   .--------------------------------------------------------------------------.",1);
  109. sm("   |            Ami-Express Diary Version 1.0 Written by ByteMaster           |",1);
  110. sm("   |                /X Development Team - The Silent Achievers                |",1);
  111. sm("   `--------------------------------------------------------------------------'",1);
  112. sm("",1);
  113. }